/**
 * Created by 瑱彬 on 2015/4/24.
 */
$(function () {
    var item_w = $(".slider-item").width();
    var item_p_l = $(".slider-item").position().left;
    $(".slider-item").css({
        position: 'absolute',
        left: item_p_l,
        width: item_w
    });
    $(".menu-link").click(function (event) {
        var linkDiv = $(this).attr('menu-link');
        $("#" + linkDiv).css({
            position: 'absolute',
            left: item_w + item_p_l
        });
        $("#" + linkDiv).show(0);
        var father = $(this);
        while (!father.hasClass("slider-item")) {
            father = father.parent();
        }
        floatRight(father, "#" + linkDiv);
    });
    var floatRight = function (el1, el2) {
        $(el2).animate({left: item_p_l}, function () {
            $(el2).scrollTop(0);
        });
        $(el1).animate({left: 0 - item_w}, function () {
            $(el1).hide(0);
        });
    }
});
